function $(id){
	return document.getElementById(id);
}

/*
 * 页面加载就获取右边广告的信息
 */
var objRight;//装广告的层
var rightWidth;//图片的宽度
var rightTop;//图片到顶端距离
var rightRight;//图片到右端距离


/*
 * 关闭固定广告
 */
function dd_close(){
	objRight.style.display="none";
}

/*
 * 滚动时改变右侧广告的位置
 */
window.onscroll = move;
function move(){
	//top字符型         				document.documentElement.scrollTop滚动条滑动的距离
	console.log(parseInt(document.documentElement.scrollTop))
	objRight.style.top = rightTop + parseInt(document.documentElement.scrollTop)+"px";
	/*objRight.style.left = parseInt(document.documentElement.scrollLeft)+parseInt(document.documentElement.clientWidth)
			-rightRight-rightWidth+"px";
	$("dd_close").style.left = "63px";//设置关闭按钮的距离*/
}




/*
 * 循环显示图片
 */
var scroll_img = new Array();//存放图片的地址
scroll_img[0] = "images/dd_scroll_1.jpg";
scroll_img[1] = "images/dd_scroll_2.jpg";
scroll_img[2] = "images/dd_scroll_3.jpg";
scroll_img[3] = "images/dd_scroll_4.jpg";
scroll_img[4] = "images/dd_scroll_5.jpg";
scroll_img[5] = "images/dd_scroll_6.jpg";

var scroll_number = new Array();
scroll_number[0] = "scroll_number_1";
scroll_number[1] = "scroll_number_2";
scroll_number[2] = "scroll_number_3";
scroll_number[3] = "scroll_number_4";
scroll_number[4] = "scroll_number_5";
scroll_number[5] = "scroll_number_6";

var nowPic =1;//先显示第一张
var MaxPic =6;//照片数量

function loopShow(d){
	if(Number(d)){//是数字
		nowPic = d;
	}
	//console.log(document.getElementsByClassName("scroll_mid")[0].getElementsByTagName("img")[0].src);
	document.getElementsByClassName("scroll_mid")[0].getElementsByTagName("img")[0].src = scroll_img[nowPic-1];
	
	$(scroll_number[nowPic-1]).className = "scroll_number_over";
	for(var i=0;i<MaxPic;i++){
		if((i+1)!=nowPic){
			$(scroll_number[i]).className = "scroll_number_out";
		}
	}
	
	//console.log(nowPic);
	nowPic++;
	if(nowPic>MaxPic){
		nowPic=1;
	}
	
}

setInterval('loopShow(nowPic)',3000);



/*
 * 文字滚动
 */
var texts = new Array();//保存所有要滚动的文字
var speed = 500;//向上滚动速度

function moveTop(){
	//将texts[0]变到最后其他的上移
	var temp = texts[0];
	for(var i=1;i<texts.length;i++){
		texts[i-1]=texts[i];
	}
	texts[texts.length-1]=temp;
	
	//设置到$("express")
	$("express").appendChild(texts[0]);
}

var myMar = setInterval("moveTop()",speed);


/*
 * 最新上架板块Tab切换效果
 */
var bookCate = new Array();
bookCate[0] = "book_history";
bookCate[1] = "book_family";
bookCate[2] = "book_culture";
bookCate[3] = "book_novel";

var bookClass = new Array();
bookClass[0] = "history";
bookClass[1] = "family";
bookClass[2] = "culture";
bookClass[3] = "novel";
//elementId   0123
function bookPutUp(elementId){
	for(var i =0;i<bookCate.length;i++){
		if(elementId==i){
			$(bookCate[i]).className = "book_show";
			$(bookCate[i]).className = "book_type_out";
		}else{
			$(bookCate[i]).className = "book_none";
			$(bookCate[i]).className = "book_type";
		}
	}
}

window.onload = function(){
	objRight = $("right");
	rightWidth = objRight.width;//图片的宽度
	
	//浏览器兼容
	if(objRight.currentStyle){//ie浏览器
		rightTop = parseInt(objRight.currentStyle.top);//图片离顶端的距离
		rightRight = parseInt(objRight.currentStyle.right);//图片右顶端的距离
	}else{
		rightTop = parseInt(document.defaultView.getComputedStyle(objRight,null).top);//图片离顶端的距离
		rightRight = parseInt(document.defaultView.getComputedStyle(objRight,null).right);
	}
	
	//保存要滚动的文字
	texts = $("express").getElementsByTagName("li");
	//console.log(texts[2].innerText);//·口述历史权威唐德刚先生国...
	
	$("express").onmouseover = function(){
		clearInterval(myMar);
	}
	
	$("express").onmouseout = function(){
		myMar = setInterval(moveTop,speed);
	}
}